import cv2


def myMatchTemplate(img, templ):
    height, width, c = templ.shape
    results = cv2.matchTemplate(img, templ, cv2.TM_CCOEFF_NORMED)
    loc = list()
    for i in range(len(results)):
        for j in range(len(results[i])):
            if results[i][j] > 0.99:
                loc.append((j, i, j + width, i + height))
    return loc


img = cv2.imread('backGround.jpg')
templs = list()
templs.append(cv2.imread('template.jpg'))
templs.append(cv2.imread('template02.jpg'))

loc = list()
for t in templs:
    loc += myMatchTemplate(img, t)

for i in loc:
    cv2.rectangle(img, (i[0], i[1]), (i[2], i[3]), (0, 0, 255), 2)

cv2.imshow('img', img)
cv2.waitKey()
cv2.destroyAllWindows()
